package edu.olin.scheduler.loader;

import edu.olin.scheduler.common.*;
import javax.swing.tree.TreeNode;

public class CategoryPrinter {
    
    public static void print(Category c){
        print(c,0);
        }
    private static void print(Category c, int indent){
        System.out.println(getIndent(indent)+"Category "+c.getName());
        for(int i=0; i<c.getChildCount(); i++){
            TreeNode t = c.getChildAt(i);
            if(t instanceof Category){ print((Category)t,indent+1); continue; }
            if(t instanceof Course){ print((Course)t,indent+1); continue; }
            System.out.println(getIndent(indent+1)+"TreeNode "+t);
            }
        }
    
    private static void print(Course c, int indent){
        System.out.println(getIndent(indent)+"Course "+c.getNumber()+":"+c.getName());
        }
    
    private static String getIndent(int indent){
        String rtn = "";
        for(int i=0; i<indent; i++){ rtn+="\t"; }
        return rtn;
        }
    
}
